class direction:
    def __init__(self, i_s, i_e, i_step, j_s, j_e, j_step, judge_x, judge_y):
        self.i_s = i_s
        self.i_e = i_e
        self.i_step = i_step
        self.j_s = j_s
        self.j_e = j_e
        self.j_step = j_step
        self.judge_x = judge_x
        self.judge_y = judge_y

ds = []
n, m, x, y, v, c = map(int, input().split())
x, y = x - 1, y - 1
# 方向类，参数有x，y坐标的起点、终点、步长、判断是否和起点同一行这几个操作。下面创建的4个对象对应4个方向
ds.append(direction(x, n, 1, y, m, 1, lambda tx:tx > x, lambda ty: ty > y))
ds.append(direction(x, n, 1, y, -1, -1, lambda tx:tx > x, lambda ty: ty < y))
ds.append(direction(x, -1, -1, y, m, 1, lambda tx:tx < x, lambda ty: ty > y))
ds.append(direction(x, -1, -1, y, -1, -1, lambda tx:tx < x, lambda ty: ty < y))
a = [i for i in range(n)]
for i in a: a[i] = [*map(int, input().split())]
mx = -1
# 然后只要遍历对象，
for d in ds:
    # 每次初始化血量dp[x][y]，
    dp[x][y] = v
    # 然后根据类中定义好的起点终点和步长来遍历
    for i in range(d.i_s, d.i_e, d.i_step):
        for j in range(d.j_s, d.j_e, d.j_step):
            # 判断不和x在一行且不和y在一列，则取两个点中较大那个。否则那个可行选那个。
            if d.judge_x(i) and d.judge_y(j):
                dp[i][j] = max(dp[i - d.i_step][j], dp[i][j - d.j_step]) + a[i][j]
            elif d.judge_x(i):
                dp[i][j] = dp[i - d.i_step][j] + a[i][j]
            elif d.judge_y(j):
                dp[i][j] = dp[i][j - d.j_step] + a[i][j]
            # 如果血量小于0就变成大负数
            if dp[i][j] < 0: dp[i][j] = - 1e12
            # 如果血量大于血量上限就改成血量上限
            if dp[i][j] > c: dp[i][j] = c
    # 最后找最大的可能值
    mx = max(mx, dp[d.i_e - d.i_step][d.j_e - d.j_step])
print(mx)
'''
啊啊啊啊！我竟然真的用这么简单干练的方法写出来了！！！！！！！
我太强了，我决定java也这么写！！！
之前我还是写4个大循环呢！
这次的写法真的太强了！！！
'''
